<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>

<script>
    // regiser.html  => 注册页 => 点击提交数据到login.html
    // login.html  => 接收注册页传递的数据并解析   => 对象 {user:"a123123",pwd,phone,email}

    // 参数数据解析  => 本质:操作字符串 => 得到想要的数据
    console.log(location);

    var search = location.search;
    console.log("search",search);

    var data = {};

    if(search){  // 判断有没有数据
       
        // var reg = /\w+=\w+/;  // \w+ 字母数字下划线,一个或多个
        var reg = /(\w+)=([^&]+)/g;  // \w+ => 键名,字母数字下划线,一个或多个   [^&]+=> 键值,(除&以外的任意字符)

        // console.log(reg.exec(search));  // ["user=a123123","user","a123123"]
        var res= null;
        while(res = reg.exec(search)){
            var key = res[1];
            var val = res[2];
            data[key] = decodeURIComponent(val);
        }
        console.log(data);
    }else{  // 没有数据 => 去注册
        location.href = "./register.html";
    }







</script>
</html>